package com.yugao.fintech.antelope.shortlink.model.mq;

import com.yugao.fintech.antelope.base.model.module.mq.AbstractMQ;
import com.yugao.fintech.antelope.base.model.module.mq.BaseMqPayload;
import com.yugao.fintech.antelope.shortlink.constants.MqCons;
import com.yugao.fintech.antelope.shortlink.model.entity.AccessLog;
import lombok.*;

/**
 * 保存访问日志消息
 */
public class SlAccessLogSaveMQ extends AbstractMQ {
    public static final String QUEUE = "short_link.access_log_save.queue";
    public static final String EXCHANGE = MqCons.EXCHANGE;
    public static final String KEY = "";

    public SlAccessLogSaveMQ(MsgPayload msgPayload) {
        super(msgPayload);
    }

    /**
     * 定义Msg消息载体
     */
    @Data
    @Builder
    @EqualsAndHashCode(callSuper = true)
    @AllArgsConstructor
    @NoArgsConstructor
    public static class MsgPayload extends BaseMqPayload {
        /**
         * 访问日志
         */
        private AccessLog accessLog;
    }

    /**
     * 构造MQModel , 一般用于发送MQ时
     */
    public static SlAccessLogSaveMQ build(AccessLog accessLog) {
        return new SlAccessLogSaveMQ(new MsgPayload(accessLog));
    }
}
